<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>后台管理系统</title>
	    <meta name="author" content="BaiYY"/>
	    <meta charset="utf-8">
	    <meta http-equiv="X-UA-Compatible" content="IE=edge">
	    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
	    <meta name="renderer" content="webkit">
	    <link rel="stylesheet" type="text/css" href="__PUBLIC__/admin/css/bootstrap.min.css"/>
	    <link rel="stylesheet" type="text/css" href="__PUBLIC__/admin/css/Font/css/font-awesome.min.css"/>
	    <link rel="stylesheet" type="text/css" href="__PUBLIC__/admin/css/index.css"/>
	    <script type="text/javascript" src="__PUBLIC__/admin/js/jquery.js"></script>
	    <script type="text/javascript" src="__PUBLIC__/admin/js/bootstrap.min.js"></script>
	    <script type="text/javascript" src="__PUBLIC__/admin/js/index.js"></script>
	    <script type="text/javascript" src="__PUBLIC__/admin/js/time.js"></script>
	    <script type="text/javascript" src="__PUBLIC__/admin/js/bootstrap-paginator.js"></script>
	</head>
	<body>
		<!--右边侧栏开始-->
		<div class="right-sidebar" style="max-width: 1200px;">
			<ul class="nav nav-tabs" style="margin-bottom: 16px" role="tablist">
				<li role="presentation" class="active"><a href="withdrawReview.html">提现审核</a></li>
				<li role="presentation"><a href="uwithdrawList.html">提现记录</a></li>
			</ul>
		
			<div class="admin_tab_cont" style="display:block;" id="tab1">
				<section class="table-responsive">
					<table class="table table-bordered" style="border: 1px solid #ddd;">
						<thead>
							<tr id="head">
								<th>流水号</th>
								<th>申请者ID</th>
								<th>手机号码</th>
								<th>提现金额</th>
								<th>提现时间</th>
								<th>操作</th>
							</tr>
						</thead>
						<tbody id="dataList"></tbody>
					</table>
					<div style="width: 100%;">
						<nav aria-label="Page navigation" >
                            <div id="example">
                                <ul id="pageShow" class="pull-left"></ul>
                            </div>
                        </nav>
					</div>
				</section>
			</div>

			<div id="bg-models">
				<div id="bg-contents">
					<i class="glyphicon glyphicon-remove" id="btn-closed"></i>
					<div class="title_dialog">系统提示！</div>
					<div class="discription_dialog">你确定要删除该条提现申请吗？</div>
					<div class="footer_dialog">
						<button class="btn btn-primary" id="btn-ok">确定</button>
						<button class="btn btn-primary" id="btn-off">取消</button>
					</div>
				</div>
			</div>

		</div>
		<script type="text/javascript">
			showpage();
			function showpage(pages){
				var page=pages?pages:1;
				$.ajax({
					type:"get",
					dataType:"json",
					url:"{:U('Admin/Main/withdrawReviewPage')}",
					data:{page:page},
					success:function(data){
//						console.log(data);
						var str = '';
						var txt = '';
						if(data != 'error') {
							for(var i=0;i<data.data.length;i++) {
								var user = data.data[i].user_id;
								if(data.data[i].state == '0') {
									txt = "封号";
								}else if(data.data[i].state == '1') {
									txt = "恢复";
								}
								str +="<tr><td class='id'>"+data.data[i].id+"</td><td>"+data.data[i].user_id+"</td><td>"+data.data[i].tel+"</td><td>"+data.data[i].withdraw+"</td><td>"+getLocalTime(data.data[i].add_time)+"</td><td><a class='btn btn-primary btn-sm' onclick='handelClick(this)'>转账</a>&emsp; <button class='btn btn-primary btn-sm' onclick='onDel(this)'>删除</button></td></tr>";
							}
							$("#dataList").html(str);
						}else{
							$("#dataList").html("没有任何数据");
						}
						
						var options = {
							currentPage: data.page,    //当前页，可以请求到数据再配置
							totalPages: data.pageSize,    //总共多少页，可以请求到数据再配置
							size:"normal",    
							bootstrapMajorVersion: 3,//bootstrap版本   
							alignment: "center", //对齐方式   
							numberOfPages:1,    //每一波显示几个
							itemTexts: function (type, page, current) {        
								switch (type) {            
									case "first": return "首页";            
									case "prev": return "上一页";            
									case "next": return "下一页";            
									case "last": return "末页";            
									case "page": return page;
								}
							},
							// 选择那页点击事件
							onPageClicked:function(event,originalEvent,type,page){
	//							console.log(page)//可以获取当前页，拿这个值去发请求即可
								showpage(page);
							},
						}
					
						$('#pageShow').bootstrapPaginator(options);
					
					}
				});
			}
			function handelClick(This) {
                var ids = $(This).closest("tr").find("td.id").text();
                console.log(ids);
                $(This).attr("href","{:U('Admin/Main/getWithdraw')}?ids=" + ids);
            }
			
			function onDel(This) {
				var id = $(This).closest("tr").find("td.id").text();
				$("#bg-models").show();
				$("#btn-ok").on("click",function () {
                    $.ajax({
                        type:"post",
                        url: "{:U('Admin/Main/withdrawReviewDel')}?id="+id,
                        success:function(data) {
                            console.log(data);
                            if(data == 'success') {
                                window.location.href="{:U('Admin/Main/withdrawReview')}";
                            }else if(data == 'error') {
                                window.location.href="{:U('Admin/Main/withdrawReview')}";
                            }
                        }
                    });
                });
                $("#btn-closed").on("click",function () {
                    $("#bg-models").hide();
                });
                $("#btn-off").on("click",function () {
                    $("#bg-models").hide();
                });
			}
		</script>
	</body>
</html>
